#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

int distMoney(int money, int children) {
    money -= children;
    if (money < 0)
        return -1;
    int res = min(money / 7, children);
    money -= res * 7;
    children -= res;
    if ((children == 0 && money > 0) || (children == 1 && money == 3))
    {
        res--;
    }
    return res;
}